package com.yfeng.common.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.yfeng.common.utils.BeanUtil;

/**
 * User: rqn
 * Date: 2009-2-18 0:18:34
 */
public class SpringLoaderListener extends ContextLoaderListener implements ServletContextListener {

    private Log log = LogFactory.getLog(SpringLoaderListener.class);
     @Override
    public void contextInitialized(ServletContextEvent event) {
        log.info("*******execute contextInitialized*********");
      //  super.contextInitialized(event);
        ServletContext context = event.getServletContext();
        ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
        //设置appliactionContext
        BeanUtil.setApplicationContext(ctx);
    }
}
